package com.link2room.jetfire.controller.api;

import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.jetfire.dto.param.api.WxPayOrderApiParamDto;
import com.link2room.common.dto.threadlocal.BaseThreadLocal;
import com.link2room.jetfire.facade.IReservationApiFacadeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created by sss on 2016/9/20.
 */
@Api(tags = "订单预下单")
@RestController
@RequestMapping("/api/WxPayOrders")
public class WxPayOrderApiController {

    @Resource
    private IReservationApiFacadeService reservationApiFacadeService;

    @ApiOperation(value = "订单预下单",response = String.class)
    @RequestMapping(method = RequestMethod.POST)
    public BaseResultDto mewReservationPay(
            @RequestBody WxPayOrderApiParamDto wxPayOrderApiParamDto
    )throws Exception{
        wxPayOrderApiParamDto.setSpBillCreateIP(BaseThreadLocal.getLocalAddr());
        String prepayId=reservationApiFacadeService.l2rPreOrder(wxPayOrderApiParamDto);
        BaseResultDto l2rRs=new BaseResultDto();
        l2rRs.setResultCode(0);
        l2rRs.setResultInfo(prepayId);
        return l2rRs;
    }
}
